package com.cxs.plan.controller.bill;

import com.cxs.plan.domain.HttpResult;
import com.cxs.plan.domain.entity.PayCard;
import com.cxs.plan.service.PayCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bill/card")
public class PayCardController {

    @Autowired
    private PayCardService payCardService;

    @GetMapping
    public HttpResult getPayCardList() {
        return HttpResult.success(payCardService.getPayCardList());
    }

    @PostMapping
    public HttpResult addPayCard(@Validated @RequestBody PayCard payCard) {
        payCardService.addPayCard(payCard);
        return HttpResult.success();
    }

    @GetMapping("/{id}")
    public HttpResult getPayCard(@PathVariable Long id) {
        return HttpResult.success(payCardService.getPayCardInfo(id));
    }

    @GetMapping("/detail/{id}")
    public HttpResult getPayCardDetail(@PathVariable Integer id) {
        return HttpResult.success(payCardService.getPayCardDetail(id));
    }

    @GetMapping("/record/{id}")
    public HttpResult getPayCardRecord(@PathVariable Integer id) {
        return HttpResult.success(payCardService.getPayCardRecord(id));
    }
}
